﻿#region
/*******************************************************************************
** File Name:		    AnnouncementSettingService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using EWineShop.Service.Contracts;
using EWineShop.Service.Model;
using EWineShop.IBatisRepository;
using EWineShop.Respository;
using System.Data;
using EWineShop.Entity;

namespace EWineShop.Service
{
    public class AnnouncementSettingService : IAnnouncementSettingService
    {
		 IAnnouncementSetting announcementSetting = new AnnouncementSettingRepository();
		 
		 #region  Auto Generation
		 

	
		public IList<AnnouncementSettingModel> GetAll ()
		{
			IList<EAnnouncementSetting> entity = announcementSetting.GetAll();
			
			if (entity == null)
            {
                return null;
            }
            
            IList<AnnouncementSettingModel> list = new List<AnnouncementSettingModel>();

            foreach (var item in entity)
            {
                AnnouncementSettingModel model = ConvertEntityToModel(item);
                list.Add(model);
            }
            return list;   
			
		}
		
		private AnnouncementSettingModel ConvertEntityToModel(EAnnouncementSetting entity)
		{
			if (entity == null)
            {
                return null;
            }
			AnnouncementSettingModel model = new AnnouncementSettingModel();
                        model.AnnouncementSettingID = entity.AnnouncementSettingID;
                        model.Content = entity.Content;
                        model.WeiboContent = entity.WeiboContent;
                        return model;
		}
		
		private EAnnouncementSetting ConvertModelToEntity(AnnouncementSettingModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAnnouncementSetting entity = new EAnnouncementSetting();
                        entity.AnnouncementSettingID = model.AnnouncementSettingID;
                        entity.Content = model.Content;
                        entity.WeiboContent = model.WeiboContent;
                        return entity;
		}
		
		
		
		#endregion
    }
}